﻿using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Scrum.Net.Classes;
using Scrum.Net.Interfaces;

namespace Scrum.NetTests
{
    [TestClass]
    public class ProjectTest
    {
        private const string Name = "Test";
        private readonly IProject _prj;

        public ProjectTest()
        {
            _prj = new Project(Name);
        }
        
        [TestMethod]
        public void TestProjectConstructor()
        {
            Assert.AreEqual(_prj.Name, Name);
            Assert.IsNotNull(_prj.Sprints);
            Assert.IsNotNull(_prj.Users);
            Assert.IsNotNull(_prj.Backlog);
            Assert.IsNotNull(_prj.Sprints);
        }

        [TestMethod]
        public void AddingSprintsToProject()
        {
            _prj.Sprints.Add(new Sprint(_prj,"Sprint 1"));
            _prj.Sprints.Add(new Sprint(_prj,"Sprint 2"));

            Assert.AreEqual(_prj.Sprints.Count, 2);
            Assert.AreEqual(_prj.Sprints[1].Name, "Sprint 2");
        }
        
        [TestMethod]
        public void AddingUserToProject()
        {
            _prj.Users.Add(new User("User 1"));
            _prj.Users.Add(new User("User 2"));

            Assert.AreEqual(_prj.Users.Count, 2);
            Assert.AreEqual(_prj.Users[1].Name, "User 2");
        }

        [TestMethod]
        public void AddingStoriesToBacklog()
        {
            _prj.Backlog.Add(new ProductStory("Test"));

            _prj.Backlog[0].Description = "Test Story Description";
            _prj.Backlog[0].Priority = 1;
        }

        [TestMethod]
        public void SaveProjectProperties()
        {
            _prj.Sprints.Add(new Sprint(_prj, "Sprint 1"));
            _prj.Sprints.Add(new Sprint(_prj, "Sprint 2"));

            //IList<string> result = _prj.SaveProperties();

            //Assert.AreEqual(result.Contains("Name="+Name), true);
        }
    }
}
